package com.chtw.vuedemo.controller;

import com.chtw.vuedemo.bean.Goods;
import com.chtw.vuedemo.response.RespUtil;
import com.chtw.vuedemo.service.impl.GoodServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author chtw
 * @date 2020-10-05 12:58
 */
@RequestMapping("/goods")
@RestController
public class GoodController {

    @Autowired
    private GoodServiceImpl goodService;

    @GetMapping("/list")
    public RespUtil<List<Goods>> list(int page) {
        try {
//            return new RespUtil<>(CodeAndMsg.SUCCESS, goodService.list(page, false));
            return RespUtil.success(goodService.list(page, false));
        } catch (Exception e) {
            return  RespUtil.fail("获取商品列表失败");
        }
    }
}
